package com.comum.javahomework420242025.utils;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;

public class LocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {

    @Override
    public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException {
        // 将字符串解析为 OffsetDateTime，然后转换为 LocalDateTime
        OffsetDateTime offsetDateTime = OffsetDateTime.parse(jsonParser.getText());
        return offsetDateTime.toLocalDateTime();
    }
}
